#include<bits/stdc++.h>
#define int long long
using namespace std;
const int Maxn = 100, Base = 233, mod = 1e9 + 7;
string s;
char a[Maxn];
int ans;
map<int, int> mp;
void dfs(char a[], int n){
	int s = 0;
	for(int i = 0 ; i < n ; i++) s = (s * Base % mod + a[i]) % mod;
	// cout << mp[s] << '\n';
	if(!mp[s]) ans++;
	if(mp[s]) return ;
	mp[s] = 1;
	for(int i = 0 ; i < n ; i++){
		if((a[i] == 'A' && a[i + 1] == 'A') || (a[i] == 'B' && a[i + 1] == 'B') || (a[i] == 'B' && a[i + 1] == 'A')){
			char b[Maxn];
			int tot = 0;
			for(int j = 0 ; j < i ; j++) b[tot++] = a[j];
			for(int j = i + 2 ; j < n ; j++) b[tot++] = a[j];
			dfs(b, tot);
		}
	}
}
signed main(){
	ios::sync_with_stdio(false);
	freopen("song.in", "r", stdin);
	freopen("song.out", "w", stdout);
	cin >> s;
	if(s.size() <= 20){
		for(int i = 0 ; i < s.size() ; i++) a[i] = s[i];
		dfs(a, s.size());
		cout << ans << '\n';
		return 0;
	}
	if(s[0] == 'B') cout << s.size() / 2 + 1 << '\n';
	else cout << (s.size() - 1) / 2 + 1 << '\n';
	cerr << clock() * 1.0 / CLOCKS_PER_SEC << "sec" << '\n';
	return 0;
}